package com.adee.nowcoder.huawei;

import java.util.Scanner;

public class T033_HJ033 {
    public static void main(String[] args) {
        System.out.println();
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            String str2 = in.nextLine();
            String[] arr = str.split("\\.");
            long a = (Long.parseLong(arr[0]) << 24)
                    + (Long.parseLong(arr[1]) << 16)
                    + (Long.parseLong(arr[2]) << 8)
                    + Long.parseLong(arr[3]);
            System.out.println(a);

            long b = Long.parseLong(str2);
            String ip = (b & (0xff << 24)) + "."
                    + (b & (0xff << 16)) + "."
                    + (b & (0xff << 8)) + "."
                    + (b & 0xff);
            System.out.println(ip);
        }
    }
}
